package com.estylesoft.pshevch.pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;

public class PageManager {
    private LoginPage loginPage;
    private MovieCardPage movieCardPage;
    private MovieListPage movieListPage;
    private WebDriver driver;

    PageManager(WebDriver driver){
        this.driver = driver;
        loginPage = initElements(new LoginPage(this));
        movieCardPage = initElements(new MovieCardPage(this));
        movieListPage = initElements(new MovieListPage(this));
    }

    private <T extends PageBase> T initElements(T page) {
        PageFactory.initElements(new DisplayedElementLocatorFactory(driver, 10), page);
        return page;
    }

    public WebDriver getDriver(){
        return driver;
    }
}
